#! /usr/bin/csh -f

##=======================================================================
##
##  run-ibm.csh
##
##  Generic batch submission script for IBM-AIX using LSF.
##
##-----------------------------------------------------------------------
## Usage for xlf compiler (default):
##   bsub < run-ibm.csh
##-----------------------------------------------------------------------
##
## This is an example script to build and run the default CAM configuration
## on an IBM SP.  The default configuration is 1.9x2.5L26, Finite-Volume
## dynamics, CLM2 land model, CICE ice model, and CAM data ocean model.
## Script will request 1 node to run with 16 MPI tasks and 4 SMP threads/task.
##
## Setting LSF options for batch queue submission.
#BSUB -a poe                     # use LSF openmp elim
##BSUB -x                         # exclusive use of node, use with regular queue (not_shared), omit for share or debug queue
##BSUB -n 64                      # bluefire setting
#BSUB -n 1                      # bluefire setting
##BSUB -R "span[ptile=64]"        # bluefire setting
#BSUB -o out.%J                  # output filename
#BSUB -e out.%J                  # error filename
##BSUB -q economy                # queue
##BSUB -q regular                 # queue
#BSUB -q debug                  # queue
##BSUB -q standby                # queue
##BSUB -q premium                # queue
##BSUB -q share                  # queue
#BSUB -J cam_forecast            # name
#BSUB -W 0:29                    # wall clock limit
#BSUB -P 35201098                # Christiane
#BSUB -B                         # Send email at dispatcha dn initiation time
##BSUB -a tv

cd ~/tstorms/source/tstorms

rm *.mod
rm *.o
rm *.exe
./compile_it tstorms_drive

#export homedir=/glade/home/zarzycki
set homedir=/glade/home/zarzycki
set datadir=/ptmp/zarzycki
#export datadir=/ptmp/zarzycki

cd $datadir

date

shopt -s nullglob
foreach f (/glade/proj3/mich1098/zarzycki/detect_files/1981/atl_30_x4_refine_nochem.cam.h1.1981*.nc)
	echo "Processing - $f"
        $homedir/tstorms/scripts/run_tstorms_general $f $datadir/output
end

##cd $homedir/tstorms/data3

#### Move filtered data into output
##mv ori_filt output/
##mv traj_filt output/

#### Move standard output to own data output
##mv output 'stats_'$DATA_YEAR

#### Remove temporary chopped files
##rm $homedir'/tstorms/data/ncep_'$DATA_YEAR'_1.nc'
##rm $homedir'/tstorms/data/ncep_'$DATA_YEAR'_2.nc'
##rm $homedir'/tstorms/data/ncep_'$DATA_YEAR'_3.nc'

date

## END LOOP

